<template>
  <view class="share">
    <view class="share-group">
      <view class="share-option" v-for="(item, index) in options" :key="index">
        <template v-if="item.type === 'share'">
          <button open-type="share">
            <image :src="item.icon" />
            <label>{{ item.label }}</label>
          </button>
        </template>
        <template v-else>
          <view @click.stop="emits('poster', item.key)">
            <image :src="item.icon" />
            <label>{{ item.label }}</label>
          </view>
        </template>
      </view>
    </view>
    <view class="cancel-btn" @click.stop="emits('close')">取消</view>
  </view>
</template>

<script setup>
import { ossImg } from "@/utils/utils";
import { defineEmits } from "vue";

const emits = defineEmits(["close", "poster"]);
const options = [
  {
    label: "发送给微信好友",
    icon: ossImg("others/component/wechat.png"),
    key: "share",
    type: "share",
  },
  {
    label: "生成商品海报",
    icon: ossImg("others/component/picture.png"),
    key: "poster",
  },
];
</script>

<style lang="less" scoped>
.poster {
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0, 0.1);
  position: fixed;
  z-index: 99999;
  top: 0;
  left: 0;
}

.share {
  .share-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 37px 52px 40px 52px;
    box-sizing: border-box;

    .share-option {
      line-height: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      font-size: 14px;

      button {
        background-color: transparent;
        padding: 0;
        margin: 0;
        line-height: 1;
        font-size: inherit;
        color: inherit;
        text-align: center;

        &::after {
          border: none;
        }
      }

      image {
        width: 52px;
        height: 52px;
        margin: 0 auto;
        margin-bottom: 9px;
        display: block;
      }
    }
  }

  .cancel-btn {
    border: none;
    background: transparent;
    border-top: 7px solid #f4f4f4;
    font-size: 18px;
    color: #0d0d0d;
    text-align: center;
    padding: 17px 0;
    line-height: 1;

    &::after {
      border: none;
    }
  }
}
</style>
